package com.xhtech.ui.view.load

import android.view.View
import androidx.annotation.IntDef
import com.xhtech.base.view.load.IListBean

/**
 *
 * @author  XQ Yang
 * @date 5/6/2018  11:54 AM
 */

interface IStateView {
    var bindView: View?

    @ViewState
    var curState: Int
    var emptyMsg:String
    var errorMsg:String
    var tvErrDes:String
    var tvRetryMsg:String
    fun showItemCount(count: Int)
    fun showSuccess()
    fun showError(msg: String? = null)
    fun showEmpty(msg: String? = null)
    fun showEmptyBtn(msg: String? = null){}
    fun showLoading()

    @ViewState
    var onStateChanged: ((Int) -> Unit)?

    var onRetry:(()->Unit)?

    fun <T, DATA : IListBean<T>> getState(bean: IStateBean<T, DATA>?): Int
    fun <T, DATA : IListBean<T>> setData(bean: IStateBean<T, DATA>?)
}


@IntDef(value = [STATE_SUCCESS, STATE_EMPTY, STATE_ERROR, STATE_LOADING,STATE_EMPTY_ERROR], flag = false)
@Retention(AnnotationRetention.SOURCE)
annotation class ViewState


interface PageStatus{
    companion object{
        const val STATE_SUCCESS = 0
        const val STATE_EMPTY = 1
        const val STATE_ERROR = 2
        const val STATE_LOADING=3
        const val STATE_EMPTY_ERROR=12  //空 带按钮

    }
}

const val STATE_SUCCESS =PageStatus.STATE_SUCCESS
const val STATE_EMPTY =PageStatus.STATE_EMPTY
const val STATE_ERROR = PageStatus.STATE_ERROR
const val STATE_LOADING=PageStatus.STATE_LOADING
const val STATE_EMPTY_ERROR=PageStatus.STATE_EMPTY_ERROR  //空 带按钮

